package com.wch.SpringBootTestDemo.defineTest;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@SuppressWarnings("all")
@Controller
@RequestMapping("/define")
public class DefineController {
	
    private final static Logger logger = LoggerFactory.getLogger(DefineController.class);

	@Autowired
	private DefineEntity defineEntity;
	
	@Autowired
	private DefineYml defineYml;
	
	@Resource
    private JdbcTemplate jdbcTemplate;
	

	
	/**
	 * 这里测试自定义文件
	 * 测试读取自定义properties形式文件内容
	 * @return
	 */
	@RequestMapping("/getDefine")
	@ResponseBody
	public String getDefineInfo(){
		String str = "test.name="+defineEntity.getPname()
		+"----test.password="+defineEntity.getPassword()
		+"---test.testUp="+defineEntity.getTestUpcase()
		+"testOnly="+defineEntity.getTestOnly();
		return str;
	}
	
	/**
	 * 这里测试读取测试自定义文件
	 * 测试读取自定义的yml形式的文件内容
	 * @return
	 */
	@ResponseBody
	@RequestMapping("/getYmlDefine")
	public String getYmlDefineInfo(){
/*		String str = "wch.baseinfo.name="+defineYml.getName()+"---wch.baseinfo.sex="+defineYml.getSex()
		+"----wch.baseinfo.age="+defineYml.getAge()+"---wch.moreInfo.addr="+defineYml.getAddr()
		+"---wch.moreInfo.hobby="+defineYml.getHobby();*/
	//	String str = "name="+defineYml.getName();
		
	/*	String str = "shop.name="+defineYml.getName()+"---baseName="+defineYml.getBaseName()
					 +"---baseSex="+defineYml.getBaseSex()+"---baseAge="+defineYml.getBaseAge()
					 +"---moreAddr="+defineYml.getAddr()+"---moreHobby="+defineYml.getHobby();
		*/
		 logger.debug("=====测试日志debug级别打印====\n");
	        logger.info("======测试日志info级别打印=====\n");
	        logger.error("=====测试日志error级别打印====\n");
	 
	        // 可以使用占位符打印出一些参数信息
	        String strrr = "blog.csdn.com/a78270528";
	        logger.info("======欢迎访问二一点的博客：{}\n", strrr);
	        
		String str = "---baseName="+defineYml.getBaseName()
		 +"---baseSex="+defineYml.getBaseSex()+"---baseAge="+defineYml.getBaseAge();
	//	String str = "---baseName="+defineYml.getBaseName();
		return str;
	}
	
	/**
	 * 连接了本机数据源，测试连接正常
	 * @return
	 */
	@ResponseBody
	@RequestMapping("/testjdbc")
	public String testJdbc(){
		String sql = "SELECT PASSWORD FROM PM_USER A WHERE USERNAME = ? ";
		String username = "sa";
		String pwd = jdbcTemplate.queryForMap(sql, new Object[]{username}).get("PASSWORD").toString();
		return pwd;
	}
	
	
	
	
}
